package com.midele.goodstuff.ui

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.midele.goodstuff.ui.theme.MidGoodStuffTheme
import com.midele.goodstuff.viewmodel.MainViewModel
import dagger.hilt.android.AndroidEntryPoint
import kotlin.getValue

@AndroidEntryPoint
class MainActivity : ComponentActivity() {

    private val viewModel: MainViewModel by viewModels()

    @OptIn(ExperimentalMaterial3Api::class)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)



        setContent {
            val systemUiController = rememberSystemUiController()
            val isDarkFont = false // 根据主题动态判断
            SideEffect {
                systemUiController.setStatusBarColor(
                    color = Color.Transparent, // 状态栏背景色
                    darkIcons = isDarkFont     // 字体颜色（true: 白色，false: 黑色）
                )
            }

            MidGoodStuffTheme {
               // HomeScreen()
                //RecordPayScreen()
                MidApp(viewModel)
            }
        }
    }
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
    Text(
        text = "Hello $name!",
        modifier = modifier
    )
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
    MidGoodStuffTheme {
        Greeting("Android")
    }
}